package com.example.mall_system.entity;

import java.util.Date;

public class User {
    private Long id;
    private String username;
    private String password;
    private Integer role; // 0-买家, 1-卖家, 2-管理员
    private String phone; // 可为 null
    private String email; // 可为 null
    private Date createTime;
    private Date updateTime;
    
    // 角色常量
    public static final int ROLE_BUYER = 0;
    public static final int ROLE_SELLER = 1;
    public static final int ROLE_ADMIN = 2;
    
    // Getters and Setters
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    public String getUsername() { return username; }
    public void setUsername(String username) { this.username = username; }
    public String getPassword() { return password; }
    public void setPassword(String password) { this.password = password; }
    public Integer getRole() { return role; }
    public void setRole(Integer role) { this.role = role; }
    public String getPhone() { return phone; }
    public void setPhone(String phone) { this.phone = phone; }
    public String getEmail() { return email; }
    public void setEmail(String email) { this.email = email; }
    public Date getCreateTime() { return createTime; }
    public void setCreateTime(Date createTime) { this.createTime = createTime; }
    public Date getUpdateTime() { return updateTime; }
    public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }
    
    // 权限判断方法
    public boolean isAdmin() {
        return ROLE_ADMIN == this.role;
    }
    
    public boolean isSeller() {
        return ROLE_SELLER == this.role;
    }
    
    public boolean isBuyer() {
        return ROLE_BUYER == this.role || this.role == null;
    }
}